// pages/login/login.js
const api = require('../../api/index.js');
Page({
    formSubmit(e) {
        let form = e.detail.value;
        api.loginUser({
            data: form
        }).then(res => {
            const {
                user,
                token
            } = res.data;
            wx.setStorageSync('token', token);
            wx.setStorageSync('user', user)
        })
    }
})